from collections.abc import Mapping

# Architecture "x86" (alias "i386", "i686")
# Special case: Breakpad uses "efl" in place of "eflags
REGISTERS_X86: Mapping[str, int] = {
    "eax": 0,
    "ecx": 1,
    "edx": 2,
    "ebx": 3,
    "esp": 4,
    "ebp": 5,
    "esi": 6,
    "edi": 7,
    "eip": 8,
    "eflags": 9,
    "efl": 9,
    "unused1": 10,
    "st0": 11,
    "st1": 12,
    "st2": 13,
    "st3": 14,
    "st4": 15,
    "st5": 16,
    "st6": 17,
    "st7": 18,
    "unused2": 19,
    "unused3": 20,
    "xmm0": 21,
    "xmm1": 22,
    "xmm2": 23,
    "xmm3": 24,
    "xmm4": 25,
    "xmm5": 26,
    "xmm6": 27,
    "xmm7": 28,
    "mm0": 29,
    "mm1": 30,
    "mm2": 31,
    "mm3": 32,
    "mm4": 33,
    "mm5": 34,
    "mm6": 35,
    "mm7": 36,
    "fcw": 37,
    "fsw": 38,
    "mxcsr": 39,
    "es": 40,
    "cs": 41,
    "ss": 42,
    "ds": 43,
    "fs": 44,
    "gs": 45,
    "unused4": 46,
    "unused5": 47,
    "tr": 48,
    "ldtr": 49,
}

# Architecture "x86_64" (alias "amd64")
REGISTERS_X86_64: Mapping[str, int] = {
    "rax": 0,
    "rdx": 1,
    "rcx": 2,
    "rbx": 3,
    "rsi": 4,
    "rdi": 5,
    "rbp": 6,
    "rsp": 7,
    "r8": 8,
    "r9": 9,
    "r10": 10,
    "r11": 11,
    "r12": 12,
    "r13": 13,
    "r14": 14,
    "r15": 15,
    "rip": 16,
    "xmm0": 17,
    "xmm1": 18,
    "xmm2": 19,
    "xmm3": 20,
    "xmm4": 21,
    "xmm5": 22,
    "xmm6": 23,
    "xmm7": 24,
    "xmm8": 25,
    "xmm9": 26,
    "xmm10": 27,
    "xmm11": 28,
    "xmm12": 29,
    "xmm13": 30,
    "xmm14": 31,
    "xmm15": 32,
    "st0": 33,
    "st1": 34,
    "st2": 35,
    "st3": 36,
    "st4": 37,
    "st5": 38,
    "st6": 39,
    "st7": 40,
    "mm0": 41,
    "mm1": 42,
    "mm2": 43,
    "mm3": 44,
    "mm4": 45,
    "mm5": 46,
    "mm6": 47,
    "mm7": 48,
    "rflags": 49,
    "es": 50,
    "cs": 51,
    "ss": 52,
    "ds": 53,
    "fs": 54,
    "gs": 55,
    "unused1": 56,
    "unused2": 57,
    "fs.base": 58,
    "gs.base": 59,
    "unused3": 60,
    "unused4": 61,
    "tr": 62,
    "ldtr": 63,
    "mxcsr": 64,
    "fcw": 65,
    "fsw": 66,
}

# Architecture "arm*" (32-bit)
# Special case: "r11" -> "fp"
REGISTERS_ARM: Mapping[str, int] = {
    "r0": 0,
    "r1": 1,
    "r2": 2,
    "r3": 3,
    "r4": 4,
    "r5": 5,
    "r6": 6,
    "r7": 7,
    "r8": 8,
    "r9": 9,
    "r10": 10,
    "r11": 11,
    "fp": 11,
    "r12": 12,
    "sp": 13,
    "lr": 14,
    "pc": 15,
    "f0": 96,
    "f1": 97,
    "f2": 98,
    "f3": 99,
    "f4": 100,
    "f5": 101,
    "f6": 102,
    "f7": 103,
    "fps": 24,
    "cpsr": 25,
    "s0": 64,
    "s1": 65,
    "s2": 66,
    "s3": 67,
    "s4": 68,
    "s5": 69,
    "s6": 70,
    "s7": 71,
    "s8": 72,
    "s9": 73,
    "s10": 74,
    "s11": 75,
    "s12": 76,
    "s13": 77,
    "s14": 78,
    "s15": 79,
    "s16": 80,
    "s17": 81,
    "s18": 82,
    "s19": 83,
    "s20": 84,
    "s21": 85,
    "s22": 86,
    "s23": 87,
    "s24": 88,
    "s25": 89,
    "s26": 90,
    "s27": 91,
    "s28": 92,
    "s29": 93,
    "s30": 94,
    "s31": 95,
}

# Architecture "arm64" (alias aarch64)
# Special cases: "x30" -> "lr", "x29" -> "fp", "x17" -> "ip1", "x16" -> "ip0"
REGISTERS_ARM64: Mapping[str, int] = {
    "x0": 0,
    "x1": 1,
    "x2": 2,
    "x3": 3,
    "x4": 4,
    "x5": 5,
    "x6": 6,
    "x7": 7,
    "x8": 8,
    "x9": 9,
    "x10": 10,
    "x11": 11,
    "x12": 12,
    "x13": 13,
    "x14": 14,
    "x15": 15,
    "x16": 16,
    "ip0": 16,
    "x17": 17,
    "ip1": 17,
    "x18": 18,
    "x19": 19,
    "x20": 20,
    "x21": 21,
    "x22": 22,
    "x23": 23,
    "x24": 24,
    "x25": 25,
    "x26": 26,
    "x27": 27,
    "x28": 28,
    "x29": 29,
    "fp": 29,
    "x30": 30,
    "lr": 30,
    "sp": 31,
    "pc": 32,
    "cpsr": 33,
    "v0": 64,
    "v1": 65,
    "v2": 66,
    "v3": 67,
    "v4": 68,
    "v5": 69,
    "v6": 70,
    "v7": 71,
    "v8": 72,
    "v9": 73,
    "v10": 74,
    "v11": 75,
    "v12": 76,
    "v13": 77,
    "v14": 78,
    "v15": 79,
    "v16": 80,
    "v17": 81,
    "v18": 82,
    "v19": 83,
    "v20": 84,
    "v21": 85,
    "v22": 86,
    "v23": 87,
    "v24": 88,
    "v25": 89,
    "v26": 90,
    "v27": 91,
    "v28": 92,
    "v29": 93,
    "v30": 94,
    "v31": 95,
}
